{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Maximum Number of Words You Can Type"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #hash-table #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #哈希表 #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: canBeTypedWords"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #可以输入的最大单词数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>键盘出现了一些故障，有些字母键无法正常工作。而键盘上所有其他键都能够正常工作。</p>\n",
    "\n",
    "<p>给你一个由若干单词组成的字符串 <code>text</code> ，单词间由单个空格组成（不含前导和尾随空格）；另有一个字符串 <code>brokenLetters</code> ，由所有已损坏的不同字母键组成，返回你可以使用此键盘完全输入的 <code>text</code> 中单词的数目。</p>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>text = \"hello world\", brokenLetters = \"ad\"\n",
    "<strong>输出：</strong>1\n",
    "<strong>解释：</strong>无法输入 \"world\" ，因为字母键 'd' 已损坏。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>text = \"leet code\", brokenLetters = \"lt\"\n",
    "<strong>输出：</strong>1\n",
    "<strong>解释：</strong>无法输入 \"leet\" ，因为字母键 'l' 和 't' 已损坏。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>text = \"leet code\", brokenLetters = \"e\"\n",
    "<strong>输出：</strong>0\n",
    "<strong>解释：</strong>无法输入任何单词，因为字母键 'e' 已损坏。\n",
    "</pre>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= text.length &lt;= 10<sup>4</sup></code></li>\n",
    "\t<li><code>0 &lt;= brokenLetters.length &lt;= 26</code></li>\n",
    "\t<li><code>text</code> 由若干用单个空格分隔的单词组成，且不含任何前导和尾随空格</li>\n",
    "\t<li>每个单词仅由小写英文字母组成</li>\n",
    "\t<li><code>brokenLetters</code> 由 <strong>互不相同</strong> 的小写英文字母组成</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [maximum-number-of-words-you-can-type](https://leetcode.cn/problems/maximum-number-of-words-you-can-type/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [maximum-number-of-words-you-can-type](https://leetcode.cn/problems/maximum-number-of-words-you-can-type/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['\"hello world\"\\n\"ad\"', '\"leet code\"\\n\"lt\"', '\"leet code\"\\n\"e\"']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        res = 0\n",
    "        for i in text.split(' '):\n",
    "            flag = 1\n",
    "            for j in i:\n",
    "                if j in brokenLetters:\n",
    "                    flag = 0\n",
    "                    break\n",
    "            if flag:\n",
    "                res += 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        sl = text.split(' ')\n",
    "        n = 0\n",
    "        for s in sl:\n",
    "            ie = False\n",
    "            if len(s.strip()) != 0:\n",
    "                for w in s:\n",
    "                    if w in brokenLetters:\n",
    "                        ie = True\n",
    "                        break\n",
    "            if not ie:\n",
    "                n += 1\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        lis = text.split()\n",
    "        ans = 0\n",
    "        for word in lis:\n",
    "            flag = True\n",
    "            for letter in brokenLetters:\n",
    "                if letter in word:\n",
    "                    flag = False\n",
    "                    break\n",
    "            ans += flag\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# class Solution:\n",
    "#     def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "#         text=text.split(\" \")\n",
    "#         ans=0\n",
    "#         for t in text:\n",
    "#             can=1\n",
    "#             for ch in t:\n",
    "#                 if ch in brokenLetters:\n",
    "#                     can=0\n",
    "#                     break\n",
    "#             ans+=can \n",
    "#         return ans\n",
    "            \n",
    "\n",
    "## 官解：\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)   # 无法输入的字符集合\n",
    "        res = 0   # 可以完全输入的单词数目\n",
    "        flag = True   # 当前字符所在单词是否可被完全输入\n",
    "        for ch in text:\n",
    "            if ch == ' ':\n",
    "                # 当前字符为空格，检查上一个单词状态，更新数目并初始化 flag\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                # 当前字符不可被输入，所在单词无法被完全输入，更新 flag\n",
    "                flag = False\n",
    "        # 判断最后一个单词状态并更新数目\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        splits = text.split()\n",
    "        ans = len(splits)\n",
    "        for word in splits:\n",
    "            for ch in word:\n",
    "                if ch in brokenLetters:\n",
    "                    ans -= 1\n",
    "                    break\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        cnt1 = 0\n",
    "        n = len(brokenLetters)\n",
    "        for i in text.split(' '):\n",
    "            cnt2 = 0\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    break\n",
    "                else:\n",
    "                    cnt2 += 1\n",
    "            if cnt2 == n:\n",
    "                cnt1 += 1\n",
    "        return cnt1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)   # 无法输入的字符集合\n",
    "        res = 0   # 可以完全输入的单词数目\n",
    "        flag = True   # 当前字符所在单词是否可被完全输入\n",
    "        for ch in text:\n",
    "            if ch == ' ':\n",
    "                # 当前字符为空格，检查上一个单词状态，更新数目并初始化 flag\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                # 当前字符不可被输入，所在单词无法被完全输入，更新 flag\n",
    "                flag = False\n",
    "        # 判断最后一个单词状态并更新数目\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        i=0\n",
    "        s=text.split()\n",
    "        for word in s:\n",
    "            j=0\n",
    "            for k in brokenLetters:\n",
    "                if(k in word):\n",
    "                    j=j+1\n",
    "            if(j==0):\n",
    "                i=i+1\n",
    "        return(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        text_list=text.split()\n",
    "        brokenLetters_set = set(brokenLetters)\n",
    "        n=len(text_list)\n",
    "        for i in text_list:\n",
    "            if set(i) & brokenLetters_set:\n",
    "                n-=1\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        sum = 0\n",
    "        for i in range(len(text.split(' '))):\n",
    "            cot = 0\n",
    "            t = text.split(' ')[i]\n",
    "            for j in range(len(t)):\n",
    "                for k in range(len(brokenLetters)):\n",
    "                    if t[j] == brokenLetters[k]:\n",
    "                        cot = 1\n",
    "            if cot != 1:\n",
    "                sum = sum + 1\n",
    "        return sum\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken =set(brokenLetters)\n",
    "        res = 0\n",
    "        flag = True\n",
    "        for ch in text:\n",
    "            if ch ==' ':\n",
    "                if flag:\n",
    "                    res+=1\n",
    "                flag=True\n",
    "            elif ch in broken:\n",
    "                flag = False\n",
    "        if flag:\n",
    "            res+=1\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        cnt = 0\n",
    "        n = len(brokenLetters)\n",
    "        for i in text.split(' '):    \n",
    "            if all([j not in i for j in brokenLetters]):\n",
    "                cnt += 1\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ans = 0\n",
    "        s = {c for c in brokenLetters}\n",
    "        for word in text.split():\n",
    "            ans += sum(c in s for c in word) ==0\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        words = text.split(\" \")\n",
    "        ans = 0\n",
    "        for a in words:\n",
    "            for x in a:\n",
    "                if x in brokenLetters:\n",
    "                    break\n",
    "            else:\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        tl=text.split()\n",
    "        count=0\n",
    "        #print(tl)\n",
    "        for i in tl:            \n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    count+=1\n",
    "                    break            \n",
    "        return len(tl)-count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)   # 无法输入的字符集合\n",
    "        res = 0   # 可以完全输入的单词数目\n",
    "        flag = True   # 当前字符所在单词是否可被完全输入\n",
    "        for ch in text:\n",
    "            if ch == ' ':\n",
    "                # 当前字符为空格，检查上一个单词状态，更新数目并初始化 flag\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                # 当前字符不可被输入，所在单词无法被完全输入，更新 flag\n",
    "                flag = False\n",
    "        # 判断最后一个单词状态并更新数目\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        words = text.split(\" \")\n",
    "        ans = len(words)\n",
    "        for word in words:\n",
    "            dic = Counter(word)\n",
    "            for c in brokenLetters:\n",
    "                if c in dic:\n",
    "                    ans -= 1\n",
    "                    break\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        cnt = 0\n",
    "        n = len(brokenLetters)\n",
    "        for i in text.split(' '):    \n",
    "            if all([j not in i for j in brokenLetters]):\n",
    "                cnt += 1\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        words = text.split(\" \")\n",
    "        ans = len(words)\n",
    "        for word in words:\n",
    "            for c in word:\n",
    "                if c in brokenLetters:\n",
    "                    ans -= 1\n",
    "                    break\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        res = 0\n",
    "        for i in text.split(' '):\n",
    "            flag = 1\n",
    "            for j in i:\n",
    "                if j in brokenLetters:\n",
    "                    flag = 0\n",
    "                    break\n",
    "            if flag:\n",
    "                res += 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        s = set(brokenLetters)\n",
    "        return sum(all(c not in s for c in w) for w in text.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)   # 无法输入的字符集合\n",
    "        res = 0   # 可以完全输入的单词数目\n",
    "        flag = True   # 当前字符所在单词是否可被完全输入\n",
    "        for ch in text:\n",
    "            if ch == ' ':\n",
    "                # 当前字符为空格，检查上一个单词状态，更新数目并初始化 flag\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                # 当前字符不可被输入，所在单词无法被完全输入，更新 flag\n",
    "                flag = False\n",
    "        # 判断最后一个单词状态并更新数目\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)   # 无法输入的字符集合\n",
    "        res = 0   # 可以完全输入的单词数目\n",
    "        flag = True   # 当前字符所在单词是否可被完全输入\n",
    "        for ch in text:\n",
    "            if ch == ' ':\n",
    "                # 当前字符为空格，检查上一个单词状态，更新数目并初始化 flag\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                # 当前字符不可被输入，所在单词无法被完全输入，更新 flag\n",
    "                flag = False\n",
    "        # 判断最后一个单词状态并更新数目\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)   # 无法输入的字符集合\n",
    "        res = 0   # 可以完全输入的单词数目\n",
    "        flag = True   # 当前字符所在单词是否可被完全输入\n",
    "        for ch in text:\n",
    "            if ch == ' ':\n",
    "                # 当前字符为空格，检查上一个单词状态，更新数目并初始化 flag\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                # 当前字符不可被输入，所在单词无法被完全输入，更新 flag\n",
    "                flag = False\n",
    "        # 判断最后一个单词状态并更新数目\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        text_arr = text.split(\" \")\n",
    "        ans = 0\n",
    "        broken_set = set(brokenLetters)\n",
    "        for s in text_arr:\n",
    "            s_set = set(s)\n",
    "            flag = False\n",
    "            if not s_set.intersection(broken_set):\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        t=text.split(' ')\n",
    "        n=len(t)\n",
    "        count=0\n",
    "        for i in range(n):\n",
    "            if set(t[i]).intersection(set(brokenLetters))==set():\n",
    "                count+=1\n",
    "        return count\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        a = text.split(\" \")\n",
    "        count = len(a)\n",
    "        for i in a:\n",
    "            print(i)\n",
    "            for j in brokenLetters:\n",
    "                print(j)\n",
    "                if j in i:\n",
    "                    count -= 1\n",
    "                    break\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        t = text.split()\n",
    "        brokenLetters = set(list(brokenLetters))\n",
    "        return sum(int(set(list(w)) & brokenLetters == set()) for w in t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        textList = text.split(\" \")\n",
    "        CopyList = textList.copy()\n",
    "        for i in brokenLetters:\n",
    "            for j in textList:\n",
    "                if i in j and j in CopyList:\n",
    "                    CopyList.remove(j)\n",
    "        return len(CopyList)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broke = set(brokenLetters)\n",
    "        lis = text.split()\n",
    "        ans = 0\n",
    "        for t in lis:\n",
    "            if all(a not in broke for a in t):\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ans=0\n",
    "        for i in text.split():\n",
    "            f=1\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    f=0\n",
    "                    break\n",
    "            ans+=f\n",
    "            \n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution(object):\n",
    "    def canBeTypedWords(self, text, brokenLetters):\n",
    "        \"\"\"\n",
    "        :type text: str\n",
    "        :type brokenLetters: str\n",
    "        :rtype: int\n",
    "        \"\"\"\n",
    "        brokenlist=list(set(brokenLetters))\n",
    "        text_=list(text.split(' '))\n",
    "        ii=0\n",
    "        for i in text_:\n",
    "            inputdata=list(set(i))\n",
    "            resultlist=[j for j in inputdata if j in brokenlist]\n",
    "            if len(resultlist)==0:\n",
    "                ii=ii+1\n",
    "        return ii"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        l = text.split()\n",
    "        count = 0\n",
    "        for i in l:\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    count += 1\n",
    "                    break\n",
    "        return len(l) - count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        cnt=0\n",
    "        for word in text.split():\n",
    "            # print(set(word) & set(brokenLetters))\n",
    "            if len(set(word) & set(brokenLetters))==0:\n",
    "                cnt+=1\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\r\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\r\n",
    "        text = text.split(' ')\r\n",
    "        ans = 0\r\n",
    "        for i in text:\r\n",
    "            if all(j not in brokenLetters for j in i):\r\n",
    "                ans += 1\r\n",
    "        return ans\r\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        s = 0\n",
    "        text = text.split(' ')\n",
    "        for i in text:\n",
    "            for j in i:\n",
    "                if j in brokenLetters:\n",
    "                    break\n",
    "            else:\n",
    "                s += 1\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ans = 0\n",
    "        s = {c for c in brokenLetters}\n",
    "        for word in text.split():\n",
    "            ans += sum(c in s for c in word) ==0\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        return sum(not (set(word) & set(brokenLetters)) for word in text.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ans = 0\n",
    "        s = {c for c in brokenLetters}\n",
    "        for word in text.split():\n",
    "            ans += sum(c in s for c in word) ==0\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        l=text.split(' ')\n",
    "        n=len(l)\n",
    "        for i in l:\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    n-=1\n",
    "                    break\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        words = text.split(\" \")\n",
    "        for r in brokenLetters:\n",
    "            text = text.replace(r, \"\")\n",
    "        words2 = text.split(\" \")\n",
    "        res = 0\n",
    "        for i in range(len(words)):\n",
    "            if words[i] == words2[i]:\n",
    "                res += 1\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        t=text.split(' ')\n",
    "        c=0\n",
    "        for i in t:\n",
    "            if all(j not in brokenLetters for j in i):\n",
    "                c+=1\n",
    "        return c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        cnt1 = 0\n",
    "        n = len(brokenLetters)\n",
    "        for i in text.split(' '):\n",
    "            cnt2 = 0\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    break\n",
    "                else:\n",
    "                    cnt2 += 1\n",
    "            if cnt2 == n:\n",
    "                cnt1 += 1\n",
    "        return cnt1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        num = 0\n",
    "        for word in text.split(' '):\n",
    "            num += 1\n",
    "            for letter in brokenLetters:\n",
    "                if letter in word:\n",
    "                    num -= 1\n",
    "                    break\n",
    "                    \n",
    "        return num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        cnt = 0\n",
    "        n = len(brokenLetters)\n",
    "        for i in text.split(' '):    \n",
    "            if all([j not in i for j in brokenLetters]):\n",
    "                cnt += 1\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text, brokenLetters):\n",
    "        words = text.split(\" \")\n",
    "        res = 0\n",
    "        for word in words:\n",
    "            flag = 0\n",
    "            for b in brokenLetters:\n",
    "                if b in word:\n",
    "                    flag = 1\n",
    "            if not flag:\n",
    "                res += 1\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        s = set(brokenLetters)\n",
    "        return sum(set(word).isdisjoint(s) for word in text.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        s = set(brokenLetters)\n",
    "        return sum(set(word).isdisjoint(s) for word in text.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ans = 0\n",
    "        s = {c for c in brokenLetters}\n",
    "        for word in text.split():\n",
    "            ans += sum(c in s for c in word) ==0\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        l = text.split()\n",
    "        broken = set(brokenLetters)\n",
    "        res = 0\n",
    "        for s in l:\n",
    "            res += all(c not in broken for c in s)\n",
    "        return res\n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ct = 0\n",
    "        text_list = text.split(\" \")\n",
    "        for word in text_list:\n",
    "            for i in word:\n",
    "                if i in brokenLetters:\n",
    "                    ct += 1\n",
    "                    break\n",
    "        return len(text_list) - ct"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        words = text.split()\n",
    "        cont = 0\n",
    "        for word in words:\n",
    "            tag = 0\n",
    "            for ch in word:\n",
    "                if ch in brokenLetters:\n",
    "                    tag = 1\n",
    "            if tag == 0:\n",
    "                cont += 1\n",
    "        return cont"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)\n",
    "        res = 0\n",
    "        flag = True\n",
    "        for ch in text:\n",
    "            if ch==' ':\n",
    "                if flag:\n",
    "                    res +=1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                flag = False\n",
    "        if flag:\n",
    "            res +=1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        brokens = set(brokenLetters)\n",
    "        result = 0\n",
    "        for it in text.split(\" \"):\n",
    "            word = it.strip()\n",
    "            is_broken = False\n",
    "            for c in word:\n",
    "                if c in brokens:\n",
    "                    is_broken = True\n",
    "            if is_broken is False:\n",
    "                result += 1\n",
    "        return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        result = 0\n",
    "        for word in text.split(' '):\n",
    "            flag = True\n",
    "            for c in word:\n",
    "                if c in brokenLetters:\n",
    "                    flag = False\n",
    "                    break\n",
    "            if flag:\n",
    "                result += 1\n",
    "        return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        nums=text.split(\" \")\n",
    "        cnt=0\n",
    "        for num in nums:\n",
    "            for i in brokenLetters:\n",
    "                if  i in num:\n",
    "                    cnt+=1\n",
    "                    break\n",
    "        if cnt>=len(nums):\n",
    "            return 0 \n",
    "        else:\n",
    "            return  len(nums)-cnt\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        text = text.split(' ')\n",
    "        res = len(text)\n",
    "        for j in text:\n",
    "            if any(letter in [k for k in j] for letter in [i for i in brokenLetters]):\n",
    "                res -= 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        text = text.split()\n",
    "        ans = 0\n",
    "        for i in range(len(text)):\n",
    "            flag = 0\n",
    "            for ch in brokenLetters:\n",
    "                if ch in text[i]:break\n",
    "                flag += 1\n",
    "            if flag==len(brokenLetters):\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        # words = text.split(\" \")\n",
    "        # for r in brokenLetters:\n",
    "        #     text = text.replace(r, \"\")\n",
    "        # words2 = text.split(\" \")\n",
    "        # res = 0\n",
    "        # for i in range(len(words)):\n",
    "        #     if words[i] == words2[i]:\n",
    "        #         res += 1\n",
    "        # return res\n",
    "\n",
    "        arr = text.split()\n",
    "        ret = len(arr)\n",
    "        for s in arr:\n",
    "            for c in s:\n",
    "                if c in brokenLetters:\n",
    "                    ret -= 1\n",
    "                    break\n",
    "        return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        brokens = set(brokenLetters)\n",
    "        result = 0\n",
    "        for it in text.split(\" \"):\n",
    "            word = it.strip()\n",
    "            is_broken = False\n",
    "            for c in word:\n",
    "                if c in brokens:\n",
    "                    is_broken = True\n",
    "                    break\n",
    "            if is_broken is False:\n",
    "                result += 1\n",
    "        return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)\n",
    "        res = 0\n",
    "        flag = True\n",
    "        for ch in text:\n",
    "            if ch == \" \":\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                flag = False\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res\n",
    "        # 暴力法\n",
    "        # wordcount = 0\n",
    "        # broken = set(brokenLetters)\n",
    "        # n = len(text)\n",
    "        # i = 0\n",
    "        # addflag = True\n",
    "        # while i < n:\n",
    "        #     if text[i] not in broken and text[i] != \" \":\n",
    "        #         i += 1\n",
    "        #         continue\n",
    "        #     elif (text[i] == \" \" or i == n - 1) and addflag:\n",
    "        #         print(\"word+1\")\n",
    "        #         wordcount += 1\n",
    "        #         addflag = True\n",
    "        #     elif text[i] in broken:\n",
    "        #         addflag = False\n",
    "        #     i += 1\n",
    "            \n",
    "        # return wordcount\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken = set(brokenLetters)\n",
    "        res = 0\n",
    "        flag = True\n",
    "        for ch in text:\n",
    "            if ch == ' ':\n",
    "                if flag:\n",
    "                    res += 1\n",
    "                flag = True\n",
    "            elif ch in broken:\n",
    "                flag = False\n",
    "        if flag:\n",
    "            res += 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        \n",
    "        word_list = text.split(' ')\n",
    "        brokenLetters_list = list(brokenLetters)\n",
    "        c = len(word_list)\n",
    "        for i in word_list:\n",
    "            for j in brokenLetters_list:\n",
    "                if j in i:\n",
    "                    c -= 1\n",
    "                    break\n",
    "        return c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "\n",
    "        temp= text.split(\" \")\n",
    "        result = 0\n",
    "        for i in temp:\n",
    "            if len(set(i) & set(brokenLetters)) == 0:\n",
    "                result += 1\n",
    "        \n",
    "        return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        s = set(brokenLetters)\n",
    "        return sum(set(word).isdisjoint(s) for word in text.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        words = text.split(' ')\n",
    "        print(words)\n",
    "        ans = len(words)\n",
    "        for word in words:\n",
    "            for ch in brokenLetters:\n",
    "                if ch in word:\n",
    "                    ans -= 1\n",
    "                    break\n",
    "                    print('1')\n",
    "                print('2')\n",
    "            print('3')\n",
    "        print('4')\n",
    "        print('ans',ans)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ans = 0\n",
    "        for t in text.split(\" \"):\n",
    "            status = True\n",
    "            for b in brokenLetters:\n",
    "                if b in t:\n",
    "                    status = False\n",
    "                    break\n",
    "            if status:\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        ltext = text.split(\" \")\n",
    "        cnt = 0\n",
    "        for i  in ltext:\n",
    "            f = True\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    f = False\n",
    "            if f:\n",
    "               cnt += 1\n",
    "        return cnt \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution(object):\n",
    "    def canBeTypedWords(self, text, brokenLetters):\n",
    "        \"\"\"\n",
    "        :type text: str\n",
    "        :type brokenLetters: str\n",
    "        :rtype: int\n",
    "        \"\"\"\n",
    "        brokenlist=list(set(brokenLetters))\n",
    "        text_=list(text.split(' '))\n",
    "        ii=0\n",
    "        for i in text_:\n",
    "            inputdata=list(set(i))\n",
    "            resultlist=[j for j in inputdata if j in brokenlist]\n",
    "            if len(resultlist)==0:\n",
    "                print('        ',i)\n",
    "                ii=ii+1\n",
    "        return ii"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        broken_set = set()\n",
    "        for c in brokenLetters: \n",
    "            broken_set.add(c)\n",
    "\n",
    "        text += \" \"\n",
    "        \n",
    "        num_complete_word = 0\n",
    "        complete = True\n",
    "\n",
    "        for c in text:\n",
    "            if c == ' ':\n",
    "                if complete:\n",
    "                    num_complete_word += 1\n",
    "                complete = True\n",
    "            elif c in broken_set:\n",
    "                complete = False\n",
    "                \n",
    "        return num_complete_word"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        def judge(word,s):\n",
    "            return all(i not in word for i in s)\n",
    "        \n",
    "        ws = text.split(' ')\n",
    "        return sum(1 for w in ws if judge(w,brokenLetters))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        list_ = text.split(' ')\n",
    "        num = 0\n",
    "        for i in list_:\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    num += 1\n",
    "                    break\n",
    "        return len(list_) - num\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        result=0\n",
    "        text_list=text.split(' ')\n",
    "        for i in text_list:\n",
    "            for j in brokenLetters:\n",
    "                if j in i:\n",
    "                    result+=1\n",
    "                    break\n",
    "        return len(text_list)-result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        list1=text.split()\n",
    "        n=len(list1)\n",
    "        for i in list1:\n",
    "            for j in i:\n",
    "                if j in brokenLetters:\n",
    "                    n-=1\n",
    "                    break\n",
    "        return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        def is_block(w):\n",
    "            print(w)\n",
    "            for ch in w:\n",
    "                if ch in brokenLetters:\n",
    "                    return True\n",
    "            return False\n",
    "        cnt = 0\n",
    "        for w in text.split(' '):\n",
    "            cnt += not is_block(w)\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:\n",
    "        count = 0\n",
    "        hax = set(brokenLetters)\n",
    "        for word in text.split():\n",
    "            count += 1\n",
    "            for i in brokenLetters:\n",
    "                if i in word:\n",
    "                    count -= 1\n",
    "                    break\n",
    "        return count\n",
    "                     \n",
    "                    "
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
